//
//  YBResourceStartPopupVC.swift
//  Moonlight
//
//  Created by Penlon Kim on 2024/1/5.
//  Copyright © 2024 Moonlight Game Streaming Project. All rights reserved.
//

import UIKit
import SnapKit

class YBResourceStartPopupVC: BaseMaskVC {
    
    // MARK: Lifecycle
    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.addSubview(bgImgView)
        bgImgView.addSubviews([titleLabel, closeBtn, progressView, percentLabel, shutdownBtn, enterBtn])
        
        bgImgView.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.width.equalTo(kScreenWidth*0.693)
        }
        
        titleLabel.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(16).priority(.high)
            make.height.equalTo(18)
        }
        
        closeBtn.snp.makeConstraints { make in
            make.size.equalTo(15)
            make.right.equalTo(-10)
            make.top.equalTo(12)
        }
        
        progressView.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(titleLabel.snp.bottom).offset(12.5)
            make.size.equalTo(90)
        }
        
        percentLabel.snp.makeConstraints { make in
            make.center.equalTo(progressView)
        }
        
        shutdownBtn.snp.makeConstraints { make in
            make.size.equalTo(CGSizeMake((kScreenWidth*0.693-90)/2, 30))
            make.top.equalTo(progressView.snp.bottom).offset(11.5)
            make.left.equalTo(25)
            make.bottom.equalTo(-23)
        }
        
        enterBtn.snp.makeConstraints { make in
            make.size.centerY.equalTo(shutdownBtn)
            make.right.equalTo(-25)
        }
        
    }
    
    // MARK: - lazy
    private lazy var bgImgView: UIImageView = {
        let iv = UIImageView(image: UIImage(named: "icon_popup_bg"))
        iv.isUserInteractionEnabled = true
        iv.bk_addCornerBorder(radius: 8, borderWidth: 0.1, borderColor: .clear)
        iv.contentMode = .scaleAspectFill
        iv.clipsToBounds = true
        return iv
    }()
    
    private lazy var closeBtn: UIButton = {
        let btn = UIButton(type: .custom)
        btn.setImage(UIImage(named: "icon_popup_close"), for: .normal)
        btn.bk_addTarget { [weak self] sender in
            self?.dismiss(animated: true, completion: nil)
        }
        return btn
    }()
    
    private lazy var titleLabel = self.bk_addLabel(text: "资源启动", font: .systemFont(ofSize: 16, weight: .medium), bgColor: .clear, textColor: ColorDef.dark27, align: .center)
    
    private lazy var progressView: BKCircleGradientProgressView = {
        let style = BKCircleGradientProgressView.Style(lineWidth: 10, progressColors: [kRGBColor(180, 172, 140)])
        let view = BKCircleGradientProgressView(style: style)
        return view
    }()
    
    private lazy var percentLabel = self.bk_addLabel(text: "100%", font: .systemFont(ofSize: 14), bgColor: .clear, textColor: kRGBColor(180, 172, 140), align: .center)
    
    private lazy var enterBtn: UIButton = {
        let btn = self.bk_addButton(type: .custom, title: "进入", font: .systemFont(ofSize: 13), bgColor: ColorDef.dark27, titleColor: .white, radius: 8)
        btn.bk_addTarget { [weak self] sender in
            guard let self = self else { return }
            
        }
        return btn
    }()
    
    private lazy var shutdownBtn: UIButton = {
        let btn = self.bk_addButton(type: .custom, title: "关机", font: .systemFont(ofSize: 13), bgColor: ColorDef.gray184, titleColor: kRGBColor(19, 25, 44), radius: 8)
        btn.bk_addTarget { [weak self] sender in
            guard let self = self else { return }
            
        }
        return btn
    }()
    
}
